package com.plum.admin.common.listener;

import com.plum.admin.common.event.LogEvent;
import com.plum.admin.modules.sys.entity.SysLog;
import com.plum.admin.modules.sys.service.ISysLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2021/8/13 16:05
 */
@Component
@Slf4j
public class LogEventListener {
    @Autowired
    private ISysLogService logService;

    @EventListener(LogEvent.class)
    public void saveLog(LogEvent event){
        SysLog log = event.getLog();
        logService.save(log);
    }
}
